﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Data;
using System.Web.UI.WebControls;
using BookingSystemModel;
using BookingSystemBLL;

public partial class Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void SUBMIT_Click1(object sender, EventArgs e)
    {
        if (this.UserName.Text.Trim().Length == 0)
        {
            Response.Write("<script >alert('请输入用户名！');</script>");
        }
        if (this.Pwd.Text.Trim().Length == 0)
        {
            Response.Write("<script >alert('请输入密码！');</script>");
        }
        DataSet ds = UserBLL.loginUser(this.UserName.Text, this.Pwd.Text);
        if (ds.Tables[0].Rows.Count > 0)
        {
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('登录成功！');</script>");
            loginValue.loginState = this.UserName.Text;
            Session["UserName"] = this.UserName.Text;
            Session["Pwd"] = this.Pwd.Text;
            Response.Redirect("MainPage.aspx");
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('用户名或密码错误！');</script>");
        }
    }
    protected void RESET_Click(object sender, EventArgs e)
    {
        this.UserName.Text = "";
        this.Pwd.Text = "";
    }
}